package com.tian.framework.security.config;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.core.Authentication;

import java.io.Serializable;

/**
 * 自定义权限认证
 */
public class GeneralPermissionEvaluator implements PermissionEvaluator {
    private static final Logger log = LogManager.getLogger(GeneralPermissionEvaluator.class);
    //普通的判断
    @Override
    public boolean hasPermission(Authentication authentication, Object target, Object permission) {
        log.info(target);//参数： @RequestBody String name 传参：#name
        log.info(permission);
        return true;
    }
    //用于ACL的访问控制
    @Override
    public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) {
        return false;
    }
}
